package com.qf.flash.ui.home.adapter;

import android.view.View;
import android.widget.ImageView;

import com.qf.flash.R;
import com.qf.flash.model.CommentBean;
import com.qf.flash.utils.ImageLoader;
import com.qf.flash.widget.RatingBarView;
import com.qf.flashlib.adapter.BaseRViewItem;
import com.qf.flashlib.adapter.RViewHolder;


/**
 * 2020/3/5 11:05
 */
public class GameCommentView extends BaseRViewItem<Object> {

    @Override
    public boolean isItemView(Object entity, int position) {
        return entity instanceof CommentBean;
    }

    @Override
    public int getItemLayout() {
        return R.layout.item_comment;
    }

    @Override
    public void convert(RViewHolder holder, Object entity, int position, int itemSize) {
        CommentBean bean = (CommentBean) entity;
        ImageView ivHead = holder.getView(R.id.iv_head);
        RatingBarView rbvStar = holder.getView(R.id.rbv_star);
        rbvStar.setStar((int) Math.round(bean.getScore()), false);
        ImageLoader.loadCircleHead(ivHead.getContext(), bean.getUserPhoto(), ivHead);
        holder.setText(R.id.tv_name, bean.getUserName())
                .setText(R.id.tv_date, bean.getCreateDate())
                .setText(R.id.tv_comment, bean.getContent());
        rbvStar.setStar((int) Math.round(bean.getScore()), false);
        if (contentHorPadding != 0) {
            View view = holder.getmConvertView();
            view.setPadding(contentHorPadding, 0, contentHorPadding, 0);
        }
    }
    public int contentHorPadding;

    public void setContentHorPadding(int contentHorPadding) {
        this.contentHorPadding = contentHorPadding;
    }
}
